package com.cardvalue.sys.mode;

import com.cardvalue.sys.entity.Address;
import com.cardvalue.sys.entity.Apply;
import com.cardvalue.sys.entity.Bank;
import com.cardvalue.sys.entity.CheckMobileRegisterAuth;
import com.cardvalue.sys.entity.Confirmlist;
import com.cardvalue.sys.entity.Coupon;
import com.cardvalue.sys.entity.Credit;
import com.cardvalue.sys.entity.FileListOnce;
import com.cardvalue.sys.entity.Industrylist;
import com.cardvalue.sys.entity.Login;
import com.cardvalue.sys.entity.Message;
import com.cardvalue.sys.entity.PostCreateAuth;
import com.cardvalue.sys.entity.SelHasLeaseContract;
import com.cardvalue.sys.entity.Shop;
import com.cardvalue.sys.entity.User;
import com.cardvalue.sys.entity.VerifyImgCode;
import com.google.gson.JsonObject;

import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Headers;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;

/**
 * Created by cardvalue on 2016/4/8.
 */
public class Service {
    /**
     * 查询银行清单
     * type为1，表示查询对公放款账户银行清单，无限制条件
     * type为2，表示查询对公还款账户银行清单，返回银行总行列表
     * type为3，表示查询对私开户银行清单，和type为2限制条件一致，
     */
    public interface GetBank{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @GET("banks")
        Call<Bank>  attempBank(@Header("X-CRM-Merchant-Id") String objectId, @Header("X-CRM-Access-Token") String accessToken,
                               @Query("where") String where);
    }




    /**
     * 查询确认清单
     * 增加传入参数type表示清单类型，1：申请信息，2：融资方案，3：融资保理通知书
     */
     public interface confirmlist{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @GET("applications/{applicationId}/confirmlists")
        Call<ArrayList<Confirmlist>>  attempConfirmlist(@Header("X-CRM-Merchant-Id") String objectId,@Header("X-CRM-Access-Token") String accessToken,
                                                        @Path("applicationId") String applicationId,@Query("where") String where);
    }


    /**
     * 验证征信报告
     */
     public  interface CreditReport{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @POST("applications/{applicationId}/creditReport")
        Call<VerifyImgCode> attempCreditReport(@Header("X-CRM-Merchant-Id") String objectId,@Header("X-CRM-Access-Token") String accessToken,
                                               @Path("applicationId") String applicationId,@Body Map<String,String> param);
    }


    /**
     * 征信验证码的获取
     */
    public  interface CreditReportVerifyCode{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @GET("verifyCode")
        Call<VerifyImgCode> attemptVerifyImgCode(@Header("X-CRM-Merchant-Id") String objectId,@Header("X-CRM-Access-Token") String accessToken,
                                                 @Query("where") String where);
    }



    /**
     * 聚信力验证第二步
     */
    public  interface   JXLGetJxlSubmitCode{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @POST("applications/{applicationId}/jxlSubmit")
        Call<User> attemJXLGetJxlSubmitCode(@Header("X-CRM-Merchant-Id") String objectId,@Header("X-CRM-Access-Token") String accessToken,
                                     @Path("applicationId") String applicationId,@Body User user);
    }




    /**
     * 聚信力验证第一步
     */
    public  interface   JXLGetVerityCode{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1"
        })
        @POST("applications/{applicationId}/jxlVerify")
        Call<User> attemJXLGetVerity(@Header("X-CRM-Merchant-Id") String objectId,@Header("X-CRM-Access-Token") String accessToken,
                                     @Path("applicationId") String applicationId,@Body User user);
    }




    /**
     * 查询检查清单  获取图片
     */
    public  interface  queryUploadFileList{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @GET("merchants/{merchantId}/newfilelists")
        Call<FileListOnce>  attemgetQueryUploadFileList(@Header("X-CRM-Merchant-Id") String objectId,
                                                        @Header("X-CRM-Access-Token") String accessToken,
                                                        @Path("merchantId") String merchantId);
    }

    //正在获取红包
    //获取商户列表

    /***
     * 获取商户列表
     */
    public interface getShop{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @GET("merchants/shops")
        Call<ArrayList<Shop>>  attemgetShop(@Header("X-CRM-Merchant-Id") String objectId,
                                            @Header("X-CRM-Access-Token") String accessToken);
    }

    /**
     * 正在获取红包
     */
    public interface getCoupon{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @GET("merchants/{merchantId}/coupons")
        Call<ArrayList<Coupon>>  attemgetCoupon(@Header("X-CRM-Merchant-Id") String objectId,
                                                @Header("X-CRM-Access-Token") String accessToken,
                                                @Path("merchantId") String merchantId);
    }

    /**
     * <P>查询消息    获取消息</P>
     */
    public interface getMessage{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @GET("messages")
        Call<ArrayList<Message>>  attemgetMessage(@Header("X-CRM-Merchant-Id") String objectId,
                                                  @Header("X-CRM-Access-Token") String accessToken,
                                                  @Query("where") String where);
    }



    /**
     * 创建申请
     */
    public interface createNewCredit{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @POST("applications")
        Call<Apply>  attemcreateNewCredit(@Header("X-CRM-Merchant-Id") String objectId,
                                          @Header("X-CRM-Access-Token") String accessToken,
                                          @Body  Apply apply);
    }



    /**
     *获取最新申请
     */
    public interface latesApplication{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
        })
        @GET("applications/{applicationId}")
        Call<Apply>  attemlatesApplication(@Header("X-CRM-Merchant-Id") String objectId,
                                           @Header("X-CRM-Access-Token") String accessToken,
                                           @Path("applicationId") String applicationId);
    }


    /**
     * 更新申请
     */
    public interface UpdateApplication{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
        })
        @PUT("applications/{applicationId}")
        Call<Apply>  attemUpdateApplication(@Header("X-CRM-Merchant-Id") String objectId,
                                           @Header("X-CRM-Access-Token") String accessToken,
                                           @Path("applicationId") String applicationId,
                                            @Body Apply apply);
    }


    /**
     * <P>获取授信</P>
     */
    public interface  getCreditLimit{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
        })
        @GET("credits/{creditId}")
        Call<Credit>  attemGetCreditLimit(@Header("X-CRM-Merchant-Id") String objectId,
                                          @Header("X-CRM-Access-Token") String accessToken,
                                          @Path("creditId") String creditId);

    }

    //credits/{creditId}



    /**
     * <p>创建授信</p>
     */
    public interface  CreateCreditLimit{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @POST("credits")
        Call<Credit>  attemCredit(@Header("X-CRM-Merchant-Id") String objectId,
                                  @Header("X-CRM-Access-Token") String accessToken,
                                  @Body Credit credit);

    }



    /**
     * <P>查询行业清单 一级</P>
     */
    public interface industrylist{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @GET("industrylists")
        Call<ArrayList<Industrylist>> attemIndustrylist(@Header("X-CRM-Merchant-Id") String objectId,
                                                        @Header("X-CRM-Access-Token") String accessToken,
                                                        @Query("where") String where);

    }


    /**
     * <p>获取融资期限的列表 </p>
     */
    public  interface getPlanFundTerm{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1"
        })
        @GET("planFundTerm")
        Call<ArrayList<SelHasLeaseContract>>  attemPlanFundTerm(@Header("X-CRM-Merchant-Id") String objectId,
                                                                @Header("X-CRM-Access-Token") String accessToken);
    }


    /**
     * <p>获取地理位置</p>
     */
    public  interface  GetAddress{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @GET("new/m/getMultiLngAndLat?address")
        Call<Address>  attemAddress(@Query("address") String address);

    }


    /**
     * <p>修改用户</p>
     */
    public interface UpdateInfo{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @PUT("merchants/{userId}")
        Call<User> attempUpdateInfo (@Header("X-CRM-Merchant-Id") String objectId,
                                     @Header("X-CRM-Access-Token") String accessToken,
                                     @Path("userId") String userId,
                                     @Body User updataInfo);
    }

    /**
     * <P>获取用户</P>
     */
    public   interface  getUserInfo{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @GET("merchants/{userId}")
        Call<User> attempGetUserInfo (@Header("X-CRM-Merchant-Id") String objectId,
                                      @Header("X-CRM-Access-Token") String accessToken,
                                      @Path("userId") String userId);
    }


    /***
     * <p>修改密码</p>
     */
    public  interface  UpdatePassword{
        @Headers({
                "X-CRM-Application-Id: "+"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @PUT("merchants/{userId}/updatePassword")
        Call<Login> attempUpdatePassword (@Header("X-CRM-Merchant-Id") String objectId,
                                          @Header("X-CRM-Access-Token") String accessToken,
                                          @Path("userId") String userId,
                                          @Body Login updataPwd);

    }

    /**
     * <p>登录的接口</p>
     */
    public interface  LoginService{
        @Headers({
                "X-CRM-Application-Id: " +"android",
                "X-CRM-Version: " + "2.0.1"
        })
        @GET("login")
        Call<Login> attemptLogin(@Query("mobilePhone") String mobilePhone,@Query("password") String password);
    }



    /**
     * <p>检查手机号是否已注册授权</p>
     */
    public  interface  CheckMobile{
        @Headers({
                "X-CRM-Application-Id: " +"android",
                "X-CRM-Version: " + "2.0.1"
        })
        @GET("checkMobilePhoneRegisterAuth/{mobilePhone}")
        Call<CheckMobileRegisterAuth> attemptCheckMobile(@Path("mobilePhone") String mobilePhone);
    }




    /**
     * <P>创建授权   同意注册授权</P>
     */
    public interface CreateAuthorization{
        @Headers({
                "X-CRM-Application-Id: " +"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @POST("authorizations")
        Call<PostCreateAuth>  attemptCreateAuthorization (@Body PostCreateAuth task);
    }

    /**
     * <P>获取图形验验证码   获取手机验证码</P>
     */
    public interface GetImgCode{
        @Headers({
                "X-CRM-Application-Id: " +"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @POST("mobilePhoneVerifyCode")
        Call<VerifyImgCode> attemptVerifyImgCode(@Body VerifyImgCode code);
    }


    /**
     * <p>注册</p>
     */
    public interface Register{
        @Headers({
                "X-CRM-Application-Id: " +"android",
                "X-CRM-Version: " + "2.0.1",
                "Content-Type: application/json"
        })
        @POST("merchantsByMobilePhone")
        Call<Login> attempRegister (@Body Login login);
    }


}
